﻿@page "/"
@using Microsoft.AspNetCore.Components.Authorization
@using System.Security.Claims

<div class="container">
    <div class="row">
        <div class="col-md-6">
            <div class="card">
                <div class="card-body">
                    <AuthorizeView>
                        <Authorized>
                            <button class="btn btn-primary">admin can click</button>
                        </Authorized>
                        <NotAuthorized>
                            <button class="btn btn-primary">user can click</button>
                        </NotAuthorized>
                    </AuthorizeView>
                </div>
                <div class="card-footer">
                    <AuthorizeView>
                        <Authorized>
                            <h3>You are authenticated</h3>
                            <h3>Your role is @context.User.Claims.FirstOrDefault(p => p.Type == ClaimTypes.Role).Value</h3>
                        </Authorized>
                        <NotAuthorized>
                            <h3>You are not authorized</h3>
                        </NotAuthorized>
                    </AuthorizeView>
                </div>
            </div>
        </div>
    </div>
</div>
